package it.uni.bo.monitoring.sla.context;

import java.util.HashMap;

public class AutomataState {
	
	private String name;
	private HashMap<String, AutomataTransition> transitions;
	private AutomataTransition errorTransition;

	public AutomataState(String name){
		this.name=name;
		this.transitions=new HashMap<String, AutomataTransition>();
		this.errorTransition=new AutomataTransition(this);
	}
	
	public AutomataState(String name, AutomataTransition et){
		this.name=name;
		this.transitions=new HashMap<String, AutomataTransition>();
		this.errorTransition=et;
	}
	
	public AutomataState(String name, HashMap<String, AutomataTransition> ts, AutomataTransition et){
		this.name=name;
		this.transitions=ts;
		this.errorTransition=et;
	}
	
	public String getName() {
		return name;
	}
	
	public AutomataTransition getTransition(String name){
		if(transitions.containsKey(name))
			return transitions.get(name);
		return errorTransition;
	}
	
	public void addTransition(AutomataTransition t){
		transitions.put(t.getLabel(), t);
	}
	
	public boolean equals(AutomataState s){
		if(s.name.equals(this.name))
			return true;
		return false;
	}

}
